<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box{
            height: 200px;
            width: 200px;
        }
        .html-content{
            background-color: red;
        }
        .css-contents{
            background-color: greenyellow;
        }
        .js-contents{
            background-color: blue;
        }
        .vuejs-content{
            background-color: chocolate;
        }
    </style>
</head>
<body>
    <div id="app">
       
        <button v-for="(item,index) in title" v-on:click="add(index)">
            {{item.item}}
        </button>
        <div id="box" v-bind:class="del">{{del}}</div>
        <div><a href="./2.html">第二个页面</a></div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
        let vm = new Vue({
            el:'#app',
            data:{
                msg:'',
                index:0,
                title:[
                    {item:'html'},
                    {item:'css'},
                    {item:'js'},
                    {item:'vue.js'}
                ],
                contents:[
                    {item:'html-content'},
                    {item:'css-contents'},
                    {item:'js-contents'},
                    {item:'vuejs-content'}
                ]
            },
            methods:{
                add(index){
                    this.index = index
                }
            },
            computed:{
                del(){
                   return this.contents[this.index].item
                }
            }
        })
        console.log(vm)
    </script>
</body>
</html>